//
//  BHFunDetailApplyInfoCell.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/6/23.
//

import UIKit

class BHFunDetailApplyInfoCell: UITableViewCell {

    @IBOutlet weak var relationStadiumView: UIView!
    @IBOutlet weak var relation_iconImageView: UIImageView!
    
    @IBOutlet weak var relation_name_label: UILabel!
    // 有场馆id的时候是10，没有的时候是-50
    @IBOutlet weak var relation_name_leading: NSLayoutConstraint!
    
    @IBOutlet weak var area_label: UILabel!
    
    @IBOutlet weak var cost_label: UILabel!
    
    @IBOutlet weak var number_label: UIButton!
    
    @IBOutlet weak var publishUser_btn: UIButton!
    
    @IBOutlet weak var publishIconImageView: UIImageView!
    
    
    var model: BHFunDetailInfoModel! {
        didSet {
            if model.venueId.isEmpty == true { // 自定义地址
                self.relation_name_leading.constant = -50;
            }else {
                self.relation_iconImageView.sd_setImage(with: URL.init(string: model.cover), completed: nil)
                self.relation_name_leading.constant = 10;
            }
            
            self.relation_iconImageView.isHidden = model.venueId.isEmpty
            self.relation_name_label.text = model.venueName
            self.area_label.text = "\(model.cityName)/\(model.areaName)"
            
            if model.price.isEmpty == true || model.price == "0" || model.price == "0.0" || model.price == "0.00"  {
                self.cost_label.text = "无需报名费"
            }else {
                self.cost_label.text = "\(model.price)元"
            }
            self.number_label.setTitle("已报名\(model.signPerson)人（剩余\(model.surplusPerson)人）", for: .normal)
            self.publishUser_btn.setTitle("\(model.launchUserName) ", for: .normal)
            self.publishIconImageView.sd_setImage(with: URL.init(string: model.launchAvatar), completed: nil)
        }
    }
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.publishIconImageView.addLayerCorner(10, 0, .white)
        self.relation_iconImageView.addLayerCorner(4, 0, .white)
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    static var cellHeight: CGFloat {
        get {
            return 291
        }
    }
    
}
